<?php

declare(strict_types=1);

namespace owns\middleware;

use Closure;
use think\Response;

/**
 * 跨域中间件
 */
class CrossMiddleware
{
    /**
     * 处理请求
     * @param Request   $request
     * @param Closure   $next
     * @return Response
     */
    public function handle($request, Closure $next)
    {
        if ($request->isOptions()) {
            return resp_header();
        }
        return resp_header($next($request));
    }
}
